//
//  NSString+Utility.m
//  OceanStaffApp
//
//  Created by Zheng on 2019/7/31.
//  Copyright © 2019 Zh. All rights reserved.
//

#import "NSString+Utility.h"

@implementation NSString (Utility)

+ (BOOL)zh_isEmptyString:(NSString *)str {

    if ([str isEqual:[NSNull null]]) {
        return YES;
    }

    if (str == nil) {
        return YES;
    }

    if ([str isKindOfClass:[NSString class]]) {
        NSString *selfstr = (NSString *)str;

        if ([selfstr isEqual:nil]) {
            return YES;
        }

        if([selfstr isEqualToString:@""]){
            return YES;
        }
    }

    if ([str isEqualToString:@"(null)"]) {
        return YES;
    }

    if ([str isEqualToString:@"null"]) {
        return YES;
    }

    if ([str isEqualToString:@"<null>"]) {
        return YES;
    }

    NSMutableString *temp = [NSMutableString stringWithString:str];
    [temp replaceOccurrencesOfString:@" " withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, str.length)];
    if ([temp isEqualToString:@""]) {
        return YES;
    }

    return NO;

}

+ (NSString *)zh_getEmptyString:(NSString *)str {
    return [NSString zh_isEmptyString:str]? @"": str;
}

@end
